import Vue from 'vue'
import Vuex from 'vuex'

import user from './modules/user'
import role from "@/store/modules/role";

// default router permission control
import createPersistedState from "vuex-persistedstate";
// import expirePlugin from "store/plugins/expire";
// 默认路由模式为静态路由 (router.config.js)

// dynamic router permission control (Experimental)
// 动态路由模式（api请求后端生成）
// import permission from './modules/async-router'

// import getters from './getters'
Vue.use(Vuex)
export default new Vuex.Store({
    modules: {
        user,
        role
    },
    state: {},
    mutations: {},
    actions: {},
    // getters
    /* vuex数据持久化配置 */
    plugins: [
        createPersistedState({
            // 存储方式：localStorage、sessionStorage、cookies
            storage: window.localStorage,
            // 存储的 key 的key值
            key: "store",
            render(state) {
                // 要存储的数据：本项目采用es6扩展运算符的方式存储了state中所有的数据
                return { ...state };
            }
        })
    ]
})
